package com.sfy.user.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sfy.user.dataObject.Instructor;
import com.sfy.user.mapper.InstructorMapper;
import com.sfy.user.service.InstructorService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;

/**
 * (Instructor)表服务实现类
 *
 * @author makejava
 * @since 2024-09-11 21:26:45
 */
@Service("instructorService")
public class InstructorServiceImpl extends ServiceImpl<InstructorMapper,Instructor>
        implements InstructorService {
    @Resource
    private InstructorMapper instructorDao;

    /**
     * 通过ID查询单条数据
     *
     * @param instructorId 主键
     * @return 实例对象
     */
    @Override
    public Instructor queryById(Integer instructorId) {
        return this.instructorDao.queryById(instructorId);
    }

    /**
     * 新增数据
     *
     * @param instructor 实例对象
     * @return 实例对象
     */
    @Override
    public Instructor insert(Instructor instructor) {
        this.instructorDao.insert(instructor);
        return instructor;
    }

    /**
     * 修改数据
     *
     * @param instructor 实例对象
     * @return 实例对象
     */
    @Override
    public Instructor update(Instructor instructor) {
        this.instructorDao.update(instructor);
        return this.queryById(instructor.getInstructorId());
    }

    /**
     * 通过主键删除数据
     *
     * @param instructorId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer instructorId) {
        return this.instructorDao.deleteById(instructorId) > 0;
    }
}
